#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :1.6 tcp服务端.py
# @Time      :2020/7/9 18:57
# @Author    :亮亮
# @说明       :tcp服务端程序
# @总结       :
import socket


def main():
    # 1.创建套接字
    tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    # 2.连接服务器
    server_ip = input("输入要连接的服务器IP：")
    server_port = int(input("输入要连接服务器的端口："))
    server_addr = (server_ip, server_port)
    tcp_socket.connect(server_addr)

    # 3.发送接收数据
    send_data = input("输入要发送的数据：")
    tcp_socket.send(send_data.encode("utf-8"))

    # 4.关闭套接字
    tcp_socket.close()


if __name__ == '__main__':
    main()
